package com.kd.d5000acquire.main;

import com.kd.d5000acquire.util.SendData;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Component
public class Main {
    public static void main(String[] args) {

         String s = "2020-06-20 19:37:48      安徽.聚安光伏   聚安光伏网络通道(JAGFNT) 退出(前置机A报警)";
         String content ="";
         String[] arr = s.split("\\s+");

        for(int j = 2 ;j < arr.length; j++){
            content += arr[j]+" " ;
        }
        System.out.println(content);
//        System.out.println(arr[0]);
//        System.out.println(arr[1]);
//        System.out.println(arr[2]);

        String s1 = "www";
        String s2 = " www";
        if(s1.trim().equals(s2.trim())){
            System.out.println("相等");
        }else{
            System.out.println("不相等");
        }


        String keyString = "abstract assert boolean break byte case catch "
                + "char class const continue default do double else enum"
                + " extends false final finally float for goto if implements "
                + "import instanceof int interface long native new null "
                + "package private protected public return short static "
                + "strictfp super switch synchronized this throw throws true "
                + "transient try void volatile while";

        String keyStr = "断 网";
        //String regex = "\\b("+keyStr+")\\b";
        String regex = "断 网";
        System.out.println(keyStr);
        String target = "2020-06-20 19:37:48      安徽.聚安光伏   聚安光通断 网(前置机A报警)";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(target);
        while(m.find()){
            System.out.println("|"+m.group()+"|");
            System.out.println(m.start());
            System.out.println(m.end());

        }
        System.out.println("it is over!");

        String  definitionId="100380000000000153";
        String  content1="aep1-ws04系统启动、系统停止!!!";
        regex="ws*系统";
        Pattern p5 = Pattern.compile(regex);
        Matcher m5 = p5.matcher(content1);
        while(m5.find()){
            System.out.println("I am here wsws!");
        }
        regex="";
        if(!(definitionId.equals("100380000000000156") || definitionId.equals("100380000000000157"))){
            //应用告警分类
            if(definitionId.equals("100380000000000153")){
                regex= "退出";
                Pattern p1 = Pattern.compile(regex);
                Matcher m1 = p1.matcher(content1);
                while(m.find()){
                    System.out.println("|"+m.group()+"|");
                    definitionId="100380000000000001";
                }
                regex="断网";
                Pattern p2 = Pattern.compile(regex);
                Matcher m2 = p2.matcher(content1);
                while(m2.find()){
                    System.out.println("|"+m.group()+"|");
                    definitionId="100380000000000003";
                }
                regex="-ws";
                Pattern p3 = Pattern.compile(regex);
                Matcher m3 = p3.matcher(content1);
                while(m3.find()){
                    System.out.println("I am here ssss!");
                }
            }
            System.out.println("I am here 11111!");
        }else{
            //链路转态，投入与退出发恢复告警
            System.out.println("I am here 22222!");
        }

        String str="aep1-wf04系统启动、系统停止!!!";
        str=str.replaceAll("-ws.+?系统", "工作站、工作站");
        System.out.println(str);


    }
}
